package com.zuowei.ycy.ui;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.and.yzy.frame.base.BaseFrameAty;
import com.zuowei.ycy.user.domain.ResultInfo;
import com.zuowei.ycy.user.util.AppJsonUtil;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;

public abstract class BaseAty extends BaseFrameAty {
    public boolean isShowToast = true;

    @Override
    public boolean setIsInitRequestData() {
        return false;
    }

    @Override
    public void btnClick(View view) {

    }

    @Override
    public void onFailure(String result, Call<ResponseBody> call, Response<ResponseBody> response, int what) {
        if (isShowToast) {
            ResultInfo resultInfo = AppJsonUtil.getResultInfo(result);
            showToast(resultInfo.getMessage());
        }

        super.onFailure(result, call, response, what);
    }


    public void initToolbar(Toolbar mToolbar,String title){
        setSupportActionBar(mToolbar);
        TextView tvTitle = (TextView) mToolbar.getChildAt(mToolbar.getChildCount()-1);
        tvTitle.setText(title);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                finish();
            }
        });

    }
}
